#include "csapp.h"
int main(){
	char *buf,*p;
	char arg1[MAXLINE],arg2[MAXLINE],content[MAXLINE];
	int a=0,b=0;
	if( (buf = getenv("QUERY_STRING") )!=NULL ){
		p=strchr(buf,'&');
		*p='\0';
		strcpy(arg1,buf);
		strcpy(arg2,p+1);
		a=atoi(arg1);
		b=atoi(arg2);
	}
	sprintf(content,"Welcome to add.com:");
	sprintf(content,"%s The Internet addition portal.\r\n<p>",content);
	sprintf(content,"%s The answer is: %d + %d = %d \r\n<p>",content,a,b,a+b);
	sprintf(content,"%s Thanks for visiting!\r\n",content);

	printf("Connection: close\r\n");
	printf("Content-length: %d\r\n",(int)strlen(content));
	printf("Content-type: text/html\r\n\r\n");
	printf("%s",content);
	fflush(stdout);
	exit(0);
}
